
package com.probiz.estore.common.model.content;

import com.probiz.estore.Constants;

public class TemplateInfo {
	private int		fileCount	= 0;

	private String	fileName;

	private boolean	isDirectory;

	private int		level;

	private String	templateCategory;

	private String	templateContent;

	private String	templateName;

	private String	templatePath;

	private String	templateType;

	public int getFileCount() {
		return fileCount;
	}

	/**
	 * @return the fileName
	 */
	public String getFileName() {
		return this.fileName;
	}

	/**
	 * @return the isDefault
	 */
	public boolean getIsDefault() {
		return this.fileName != null && this.fileName.startsWith("default")
				&& this.fileName.endsWith(".jsp");
	}

	/**
	 * @return the isDirectory
	 */
	public boolean getIsDirectory() {
		return this.isDirectory;
	}

	/**
	 * @return the level
	 */
	public int getLevel() {
		return this.level;
	}

	/**
	 * @return the templateCategory
	 */
	public String getTemplateCategory() {
		return this.templateCategory;
	}

	/**
	 * @return the templateContent
	 */
	public String getTemplateContent() {
		return this.templateContent;
	}

	/**
	 * @return the templateName
	 */
	public String getTemplateName() {
		return this.templateName;
	}

	/**
	 * 相对于web的路径，也就是说包括模板包的路径在内
	 * 
	 * @return the templatePath
	 */
	public String getTemplatePath() {
		return this.templatePath;
	}

	/**
	 * @return the templateType
	 */
	public String getTemplateType() {
		return this.templateType;
	}

	/**
	 * 用于SpringMvc的ViewName，即是在模板包内的相对路径，并且去掉/pages/前缀和.jsp后缀
	 * 
	 * @return
	 */
	public String getViewName() {
		if (templatePath == null || templatePath.indexOf(".") == -1) {
			return "";
		}
		if (templatePath.endsWith(".jsp")) {
			return this.templatePath.substring(templatePath
					.indexOf(Constants.PAGES_PREFIX)
					+ Constants.PAGES_PREFIX.length(), templatePath
					.lastIndexOf("."));
		} else if (templatePath.endsWith(".vm")) {
			return this.templatePath.substring(templatePath
					.indexOf(Constants.VELOCITY_PREFIX)
					+ Constants.VELOCITY_PREFIX.length());
		}
		return templatePath;
	}

	public void setFileCount(int fileCount) {
		this.fileCount = fileCount;
	}

	/**
	 * @param fileName
	 *            the fileName to set
	 */
	public void setFileName(String fileName) {
		this.fileName = fileName;
	}

	/**
	 * @param isDirectory
	 *            the isDirectory to set
	 */
	public void setIsDirectory(boolean isFolder) {
		this.isDirectory = isFolder;
	}

	/**
	 * @param level
	 *            the level to set
	 */
	public void setLevel(int level) {
		this.level = level;
	}

	/**
	 * @param templateCategory
	 *            the templateCategory to set
	 */
	public void setTemplateCategory(String templateCategory) {
		this.templateCategory = templateCategory;
	}

	/**
	 * @param templateContent
	 *            the templateContent to set
	 */
	public void setTemplateContent(String content) {
		this.templateContent = content;
	}

	/**
	 * @param templateName
	 *            the templateName to set
	 */
	public void setTemplateName(String templateName) {
		this.templateName = templateName;
	}

	/**
	 * @param templatePath
	 *            相对于web的路径，也就是说包括模板包的路径在内
	 * 
	 */
	public void setTemplatePath(String filePath) {
		this.templatePath = filePath;
	}

	/**
	 * @param templateType
	 *            the templateType to set
	 */
	public void setTemplateType(String templateType) {
		this.templateType = templateType;
	}

}
